#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        map<string, function<int(int, int)>> m1({
            {"+",[](int x, int y) {return x + y; }}
            ,{"-",[](int x, int y) {return x - y; }}
            ,{"*",[](int x, int y) {return x * y; }}
            ,{"/",[](int x, int y) {return x / y; }}
            });

        stack<int> st1;
        for (auto& e : tokens)
        {
            if (m1.count(e))
            {
                int right = st1.top();
                st1.pop();

                int left = st1.top();
                st1.pop();

                st1.push(m1[e](left, right));
            }
            else
            {
                st1.push(stoi(e));
            }
        }

        return st1.top();
    }
};